from pydantic_settings import BaseSettings, SettingsConfigDict
from typing import Optional, Dict, Any

class Settings(BaseSettings):
    model_config = SettingsConfigDict(
        env_file=".env",
        env_file_encoding='utf-8',
        extra="ignore"
    )

    APP_NAME: str = "visualgpt-2api"
    APP_VERSION: str = "1.0.0"
    DESCRIPTION: str = "一个将 visualgpt.io 转换为兼容 OpenAI 格式 API 的高性能代理。"

    API_MASTER_KEY: Optional[str] = None
    VISUALGPT_COOKIE: Optional[str] = None

    API_REQUEST_TIMEOUT: int = 300
    POLLING_INTERVAL: int = 3 # 轮询间隔（秒）
    POLLING_TIMEOUT: int = 240 # 轮询超时（秒）
    NGINX_PORT: int = 8088

    # 模型名称到 API 参数的映射
    MODEL_CONFIG: Dict[str, Dict[str, Any]] = {
        "nano-banana": {"type": 61, "sub_type": 2, "description": "Nano Banana - 快速精准的图像编辑。"},
        "seedream-4.0": {"type": 61, "sub_type": 3, "description": "Seedream 4.0 - 创建、编辑和统一 4K 图像。"},
        "background-remover": {"type": 60, "sub_type": 2, "description": "Background Remover - 自动移除背景，仅需上传图片。"},
        "flux-kontext-pro": {"type": 61, "sub_type": 3, "description": "Flux Kontext-Pro - 高质量图像编辑 (参数同 Seedream 4.0)。"}
    }
    DEFAULT_EDIT_MODEL: str = "nano-banana"

settings = Settings()
